package a07_二叉树;

/**
 * <p>
 * a15_左叶子之和复习2
 * </p>
 *
 * @author flyduck
 * @since 2025/2/9
 */
public class a15_左叶子之和复习2 {
    public int sumOfLeftLeaves(TreeNode root) {
        if (root == null) {
            return 0;
        }
        int leftNums = sumOfLeftLeaves(root.left);
        if(root.left != null && root.left.left == null && root.left.right == null){
            leftNums = root.left.val;
        }
        int rightNums = sumOfLeftLeaves(root.right);
        return leftNums + rightNums;
    }
}
